#!/usr/bin/env python
# -*-coding:UTF-8-*-
# Author: chenzuoqing@126.com
# Create: 2018/7/24 10:55
# File  : filter.py

"""

"""

import django_filters
from django.db.models import Q
from idcs.models import Idc


class IdcFilter(django_filters.FilterSet):
    """
    idc filter
    """
    mix_info = django_filters.CharFilter(method='multi_filter')

    def multi_filter(self, queryset, name, value):
        return queryset.filter(Q(name__icontains=value) | Q(email__icontains=value) |
                               Q(manage__icontains=value) | Q(letter__icontains=value))

    class Meta:
        model = Idc
        fields = ['name', ]
